/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import React from "react";
import { Drawer } from "antd";
import SiderMenu from "./SiderMenu";
import { getFlatMenuKeys } from "./SiderMenuUtils";

const SiderMenuWrapper = props => {
  const { isMobile, collapsed, menuData } = props;
  const flatMenuKeys = getFlatMenuKeys(menuData);
  return isMobile ? (
    <Drawer
      visible={!collapsed}
      placement="left"
      style={{
        padding: 0
      }}
      onClose={() => {
        props.onCollapse(true);
      }}
    >
      <SiderMenu {...props} flatMenuKeys={flatMenuKeys} collapsed={isMobile ? false : collapsed} />
    </Drawer>
  ) : (
    <SiderMenu {...props} flatMenuKeys={flatMenuKeys} />
  );
};

export default SiderMenuWrapper;
